<template>
  <div>
    <el-table :data="members">
      <el-table-column  label="头像" width="80">
        <template slot-scope="scope">
          <img :src="getImgUrl(scope.row.pmIcon)" style="width:40px;height: 40px">
        </template>
      </el-table-column>
      <el-table-column prop="pid" label="人员编号" width="200px"/>
      <el-table-column prop="pmUn" label="用户名" width="100px"/>
      <!--<el-table-column prop="pmPwd" label="密码" width="100px"/>-->
      <el-table-column prop="pmCreatetime" :formatter="dateFormat" label="创建时间" width="150px"/>
      <el-table-column prop="pmLastlogin" :formatter="dateFormat" label="最后登录时间" width="150px"/>
      <el-table-column prop="pmArea" label="所属地区" width="100px"/>
      <el-table-column prop="pmStatus" label="当前状态" width="100px"/>
    </el-table>
    <el-pagination
      background
      layout="prev,pager,next"
      @current-change="currPageChange"
      :current-page.sync="currPage"
      :pageSize="pageInfo.pageSize"
      :total="pageInfo.itemCount"
    >
    </el-pagination>
  </div>
</template>

<script>
  import api from "../../../../axios/api.js"
  import * as fecha from "element-ui/lib/utils/date";
  import utilsFD from "../../../../static/js/utils/index.js"

  export default {
    name: "demo1",
    data() {
      return {
        members: [],
        currPage: 1,
        pageInfo: {},
        fechaNew: fecha
      }
    },
    methods: {
      getImgUrl: function (imgsrc) {
        return "../../../static/images/scrolls/" + imgsrc;
      },
      dateFormat(row, column, cellValue) {
        return utilsFD.FD.Fd().dateFormatCN(cellValue, 'yyyy-MM-dd HH:mm:ss', fecha);
      },
      getListByPage: function () {
        api.setDataFromAxios("/api/psManagerController/getPsManagerByPage", {
          "currPage": this.currPage,
          "pageSize": this.pageInfo.pageSize
        }, "post", null).then(
          //默认返回就是response对象
          dto => {
            console.log(dto);
            this.members = dto.tList;
            this.pageInfo = dto.obj;
          }
        ).catch(function (reason) {
          console.log(reason)
        });
      },
      currPageChange: function () {
        this.getListByPage();//当用户选择页码，选中的页码自动同步给currPage，再调用重新分页查询当前页方法
      }
    },
    created: function () {
      this.getListByPage();
    }
  }
</script>

<style scoped>

</style>
